# -*- coding: utf-8 -*-

#系统用户 - 登录验证
def _api_login(_request):
    """
    /api/login  功能：系统登录验证 编写：宋德聪

    :param _request:={"RequestBaseHeader":{"SeesionKey":null,"TimeSpan":"2016-08-22 10:36:53"},"LoginName":"","LoginPWD":""}
    :param _request["LoginName"]:登录名称
    :param _request["LoginPWD"]:加密后的登录密码

    :return: _respon返回信息={"ErrorInfo":{"ErrorCode":"0","ErrorMsg":""},"IsError":false,"ReturnValue":false,"UserInfo":{"UserID":0,"UserName":"","LoginName":"","SessionKey":""}}
    :param _respon["UserInfo"]:字典类型
    :param _respon["UserID"]:用户ID
    :param _respon["UserName"]:用户名称
    :param _respon["LoginName"]:登录名称
    :param _respon["SessionKey"]:SessionKey验证

    """
    _respon = {"ErrorInfo": {"ErrorCode": "0", "ErrorMsg": ""}, "ReturnValue": "", "IsError": "",
               "UserInfo": {"UserID": "0", "UserName": "", "LoginName": ""}}

    cs_login_IsOk = False

    if _request["LoginName"] == "admin" and _request["LoginPWD"] == "375eb721e7df557d40eb64b14728ee46":
        cs_login_IsOk = True
        _respon["ErrorInfo"]["ErrorCode"] = "0"
        _respon["ErrorInfo"]["ErrorMsg"] = ""
        _respon["IsError"] = False
        _respon["ReturnValue"] = True
        _respon["UserInfo"]["UserID"] = "1001"
        _respon["UserInfo"]["UserName"] = "管理员"
        _respon["UserInfo"]["LoginName"] = "ccihadmin"
    else:
        if _request["LoginName"] == "cccghr" and _request["LoginPWD"] == "25c14a38edc2d2823cd31d7c900c64bc":
            cs_login_IsOk = True
            _respon["ErrorInfo"]["ErrorCode"] = "0"
            _respon["ErrorInfo"]["ErrorMsg"] = ""
            _respon["IsError"] = False
            _respon["ReturnValue"] = True
            _respon["UserInfo"]["UserID"] = "10012"
            _respon["UserInfo"]["UserName"] = "招聘专员"
            _respon["UserInfo"]["LoginName"] = "cccghr"
        else:
            cs_login_IsOk = False
            _respon["ErrorInfo"]["ErrorCode"] = "1"
            _respon["ErrorInfo"]["ErrorMsg"] = "账号不存在或密码错误，请重新输入！"
            _respon["IsError"] = True
            _respon["ReturnValue"] = False
            _respon["UserInfo"]["UserID"] = "0"
            _respon["UserInfo"]["UserName"] = ""
            _respon["UserInfo"]["LoginName"] = ""

    return _respon